package org.xingyun.utils;

import com.alibaba.druid.pool.DruidDataSourceFactory;

import javax.sql.DataSource;
import java.io.InputStream;
import java.util.Properties;

public class DataSourcesUtils {
    private static DataSource dataSource;

    static {
        try {
            InputStream in = DataSourcesUtils.class.getClassLoader().getResourceAsStream("druid.properties");
            Properties properties = new Properties();
            properties.load(in);
            dataSource = DruidDataSourceFactory.createDataSource(properties);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private DataSourcesUtils() {
    }

    //返回连接池
    public static DataSource getDataSource() {

        return dataSource;
    }
}
